package com.example.pojo;

import com.example.resule.ResultEnum;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@AllArgsConstructor //生成有参构造方法
@NoArgsConstructor  //生成无参构造方法
public class GuliException extends RuntimeException {
    private Integer code;//状态码
    private String message;  //异常处理
    private Exception e;

    //有参的构造方法
    public GuliException(String message) {
        super(message);
        this.message = message;

    }

    public GuliException(ResultEnum resultEnum, String message) {
        super(message);
        this.message = resultEnum.getMessage();
        this.code = resultEnum.getCode();

    }

    public GuliException(ResultEnum resultEnum) {
        super(resultEnum.getMessage());
        this.message = resultEnum.getMessage();
        this.code = resultEnum.getCode();

    }

    public GuliException(Integer code, String message) {
        super(message);
        this.code = code;
        this.message = message;

    }

    // 用指定的详细信息和原因构造一个新的异常
    public GuliException(String message, Throwable cause, Exception e) {

        super(message, cause);
        this.e = e;
    }

    //用指定原因构造一个新的异常
    public GuliException(Throwable cause) {

        super(cause);
    }


}
